#ifndef UnstuctMG_BINSEARCH_HPP
#define UnstuctMG_BINSEARCH_HPP

template<typename idx_t>
idx_t my_BinarySearch(idx_t *list, idx_t value, idx_t list_length)
{
   idx_t low, high, m;
   idx_t not_found = 1;

   low = 0;
   high = list_length - 1;
   while (not_found && low <= high)
   {
      m = (low + high) / 2;
      if (value < list[m])
      {
         high = m - 1;
      }
      else if (value > list[m])
      {
         low = m + 1;
      }
      else
      {
         not_found = 0;
         return m;
      }
   }
   return -1;
}

#endif